﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Testing
{
    public partial class Form1 : Form
    {
        public static string myConnectionString = @"Data Source=ROGERJENKINS-DT\SQLEXPRESS;Initial Catalog=RabbitSoftware;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False";
        public static DataTable EmployeeLogin = new DataTable("EmployeeLogin");
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            FillData();
        }

        void FillData()
        {
            // 1
            // Open connection
            using (SqlConnection c = new SqlConnection(myConnectionString))
            {
                c.Open();
                // 2
                // Create new DataAdapter
                using (SqlDataAdapter a = new SqlDataAdapter("SELECT * FROM EmployeeLogin", c))
                {
                    // 3
                    // Use DataAdapter to fill DataTable
                    DataTable t = new DataTable();
                    a.Fill(t);

                    // 4
                    // Render data onto the screen
                    // dataGridView1.DataSource = t; // <-- From your designer
                }
            }
        }

        public DataTable GetData()
        {
            DataTable dt = new DataTable();

            try
            {
                SqlConnection conn = new SqlConnection(myConnectionString);
                conn.Open();
                string query = "SELECT * FROM EmployeeLogin";
                SqlCommand cmd = new SqlCommand(query, conn);

                
                //dt.Load(cmd.ExecuteReader());
            }
            catch(SqlException E)
            {
                MessageBox.Show(E.Message);
            }
            return dt;
        }
    }
}
